<?php

namespace App\Http\Common;

use App\Models\Store;

/**
 * 公共返佣、计算比例类
 * Class Proportion
 * @package App\Http\Common
 */
class Proportion
{
    // todo 会员支付给商家后流入奖金池的比例
    public static function bonusPoolProportion($store_id)
    {
        $store = Store::where('id', $store_id)->first();
        if ($store->bonus_pool_proportion && $store->bonus_pool_proportion != 0) {
            return $store->bonus_pool_proportion;
        } else {
            return Constant::BONUS_POOL_PROPORTION;
        }
    }

    //  todo 会员支付给商家后给商家的收益比例
    public static function storeIncomeProportion($store_id)
    {
        $store = Store::where('id', $store_id)->first();
        if ($store->bonus_pool_proportion && $store->bonus_pool_proportion !=0) {
            return 1 - $store->bonus_pool_proportion;
        } else {
            return Constant::STORE_INCOME_PROPORTION;
        }
    }

    // todo 商家提现手续费比例
    public static function storeCashProportion($store_id)
    {
        $store = Store::where('id', $store_id)->first();
        if ($store->cash_proportion && $store->cash_proportion != 0) {
            return $store->cash_proportion;
        } else {
            return Constant::STORE_CASH_PROPORTION;
        }
    }

    // todo 商家提现收益比例
    public static function storeIncomeCashProportion($store_id)
    {
        $store = Store::where('id', $store_id)->first();
        if ($store->cash_proportion && $store->cash_proportion != 0) {
            return 1 - $store->cash_proportion;
        } else {
            return 1- Constant::STORE_CASH_PROPORTION;
        }
    }
}